package com.ymatou.iapi.im.testcase;

import com.google.common.reflect.TypeToken;
import com.google.gson.JsonObject;
import com.ymatou.iapi.im.parameter.GetMessageListAndSessionByTimelineBean;
import com.ymatou.iapi.im.parameter.SendMessageToBuyerBean;
import com.ymatou.iapi.im.parameter.SendMessageToSellerBean;
import com.ymatou.iapi.im.parameter.SetBizStatusBean;
import com.ymatou.iapi.im.parameter.YmtMessageSession;
import com.ymatou.iapi.im.parameter.emu.MessageIsNewType;
import com.ymatou.iapi.im.service.GetMessageListAndSessionByTimelineCall;
import com.ymatou.iapi.im.service.SetBizStatusCall;
import com.ymatou.iapi.userregister.parameter.UserRegisterInfoRequestDtoBean;
import com.ymatou.iapi.userregister.service.UserRegisterInfoRequestDtoCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.ImCallService;
import com.ymttest.business.service.JUserCallService;
import com.ymttest.database.model.YmtMessage;
import com.ymttest.database.model.YmtMessageAttach;
import com.ymttest.database.sqlwapper.ImDefaultWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.YMTDateUtil;

import org.apache.http.client.ClientProtocolException;
import org.junit.*;
import org.junit.experimental.categories.Category;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
*用户获取私信消息和会话信息
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetMessageListAndSessionByTimeline{
	private static GetMessageListAndSessionByTimelineBean getmessagelistandsessionbytimelineBean;
	private static GetMessageListAndSessionByTimelineCall getmessagelistandsessionbytimelineCall;
	private static int imId = Integer.parseInt(EnvSetup.getData("userId_IM"));
	private static int sellerId = Integer.parseInt(EnvSetup.getData("autotest_seller1"));
	private static String imName = EnvSetup.getData("userName_IM");
	private static int sellerId1 = Integer.parseInt(EnvSetup.getData("autotest_seller_z"));
	private static ImDefaultWapper imDefaultWapper = new ImDefaultWapper();
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("用户获取私信消息和会话信息");
	}

	@Before
	public void caseUp() {
		getmessagelistandsessionbytimelineBean=new GetMessageListAndSessionByTimelineBean();
		getmessagelistandsessionbytimelineCall=new GetMessageListAndSessionByTimelineCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getmessagelistandsessionbytimelineCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	private void setBizStatus(String messageId,int status) throws ClientProtocolException, IOException {
		SetBizStatusBean setbizstatusBean=new SetBizStatusBean();
		SetBizStatusCall setbizstatusCall=new SetBizStatusCall();
		setbizstatusBean.setBizStatus(status);
		setbizstatusBean.setMessageId(messageId);
		setbizstatusCall.setData(setbizstatusBean);
		setbizstatusCall.callService();			
	}
	/**
	 * isnew参数：
	 * yes是查传入时间之后的消息，正序
	 * no是查传入时间之前的消息，倒序
	 */

	public void checkYmtMessageSession(GetMessageListAndSessionByTimelineBean getMessageListAndSessionBean) throws InterruptedException, IOException {
		ImDefaultWapper im = new ImDefaultWapper();
		YmtMessageSession messageSession = (YmtMessageSession)FormatUtil.GSONToObject(getmessagelistandsessionbytimelineCall.getJsonObject().get("Result").getAsJsonObject().get("YmtMessageSession").toString(),YmtMessageSession.class);
		Map sessionmMap = im.selectTotalCount(getMessageListAndSessionBean.getFromUserId(),getMessageListAndSessionBean.getToUserId()).get(0);
		Logger.debug("map:" + sessionmMap);
		String userSessionId = getMessageListAndSessionBean.getFromUserId() + "_" + getMessageListAndSessionBean.getToUserId();
		if(userSessionId.equals(messageSession.getUserSessionId())){
			Logger.verifyEquals(messageSession.getFromUserName(),JUserCallService.GetUserInfo(getMessageListAndSessionBean.getFromUserId()).getLoginId(),"验证FromUserName");
			Logger.verifyEquals(messageSession.getFromUserLogo(),JUserCallService.GetLogoUrl(getMessageListAndSessionBean.getFromUserId()),"验证FromUserLogo");
			Logger.verifyEquals(messageSession.getToUserName(),JUserCallService.GetUserInfo(getMessageListAndSessionBean.getToUserId()).getLoginId(),"验证ToUserName");
			Logger.verifyEquals(messageSession.getToUserLogo(),JUserCallService.GetLogoUrl(getMessageListAndSessionBean.getToUserId()),"验证ToUserLogo");
			Logger.verifyEquals(messageSession.isImportant(),Integer.parseInt(sessionmMap.get("IsImportant").toString())==0?false:true,"验证Slient");
			Logger.verifyEquals(messageSession.isSlient(),Integer.parseInt(sessionmMap.get("Slient").toString())==0?false:true,"验证Translate");
			Logger.verifyEquals(messageSession.isSlient(),false,"验证Translate");
		}
	}
	public void checkMessage(GetMessageListAndSessionByTimelineBean getMessageListAndSessionBean) throws InterruptedException {
		ImDefaultWapper im = new ImDefaultWapper();
		int fromUserId = getMessageListAndSessionBean.getFromUserId();
		int toUserId = getMessageListAndSessionBean.getToUserId();
		List<YmtMessage> ymtMessageMap = im.selectMessageByToUserIdAndFromUserId(fromUserId,toUserId);
		Logger.debug("ymtMessageMap:"+ymtMessageMap);
		String ymtMessageList = getmessagelistandsessionbytimelineCall.getJsonObject().get("Result").getAsJsonObject().get("YmtMessageList").getAsJsonArray().toString();
		List<com.ymatou.iapi.im.parameter.YmtMessage > ymtMessages = (List<com.ymatou.iapi.im.parameter.YmtMessage>)FormatUtil.GSONToObject(ymtMessageList, new TypeToken<List<com.ymatou.iapi.im.parameter.YmtMessage >>(){}.getType());
		Logger.debug("ymtMessages:"+ymtMessages);
		String messageId = null;
		for (int j=0;j<ymtMessageMap.size();j++){
			messageId = ymtMessageMap.get(j).getMsgFromId()+"_"+ymtMessageMap.get(j).getMsgToId()+"_"+ymtMessageMap.get(j).getMessageId();
			for (int i=0;i<ymtMessages.size();i++){
				if (messageId.equals(ymtMessages.get(i).getMessageId())){
					Logger.verifyEquals(ymtMessages.get(i).getMsgFromId(),ymtMessageMap.get(j).getMsgFromId(),"验证fromUserId");
					Logger.verifyEquals(ymtMessages.get(i).getMsgToId(),ymtMessageMap.get(j).getMsgToId(),"验证toUserId");
					Logger.verifyEquals(ymtMessages.get(i).getMsgFrom(),ymtMessageMap.get(j).getMsgFrom(),"验证MsgFrom");
					Logger.verifyEquals(ymtMessages.get(i).getMsgTo(),ymtMessageMap.get(j).getMsgTo(),"验证MsgTo");
					Logger.verifyEquals(ymtMessages.get(i).getMessage(),ymtMessageMap.get(j).getMessage(),"验证Message");
					Logger.verifyEquals(ymtMessages.get(i).getCsName(),ymtMessageMap.get(j).getCsName(),"验证CsName");
					Logger.verifyEquals(ymtMessages.get(i).getSessionNumber(),ymtMessageMap.get(j).getSessionNumber(),"验证SessionNumber");
					if (ymtMessages.get(i).isCancel()==true){
						YmtMessageAttach ymtMessageAttach = im.selectMessageattachByMessageId(messageId).get(0);
						Logger.verifyEquals(ymtMessages.get(i).getMessageAttachList().get(0).getContent(),ymtMessageAttach.getContent(),"验证MessageAttachList中的Content");
						Logger.verifyEquals(ymtMessages.get(i).getMessageAttachList().get(0).getType(),ymtMessageAttach.getType(),"验证MessageAttachList中的type");
					}
				}
			}
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetMessageListAndSessionByTimeline_001() {
		Logger.start(true,"用户获取私信消息和会话信息,给买手发送消息，isNew为No");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			Integer userId = urrc.getUserid();
			SendMessageToSellerBean sendMessageToSellerBean = ImCallService.initSendMessageToSellerBean(userId,sellerId,"你好，im");
			ImCallService.SendMessageToSeller(sendMessageToSellerBean);

			getmessagelistandsessionbytimelineBean = ImCallService.initGetMessageListAndSessionByTimelineBean(userId,sellerId);
			getmessagelistandsessionbytimelineBean.setIsNew(MessageIsNewType.No);
			//传现在的时间
			getmessagelistandsessionbytimelineBean.setLongTimeline(YMTDateUtil.getDate().getTime());
			getmessagelistandsessionbytimelineCall.setData(getmessagelistandsessionbytimelineBean);
			getmessagelistandsessionbytimelineCall.callService();
			Logger.verifyEquals("Success",getmessagelistandsessionbytimelineCall.getString("Status"),"验证Status");
			//查到消息
			checkYmtMessageSession(getmessagelistandsessionbytimelineBean);
			checkMessage(getmessagelistandsessionbytimelineBean);

			//传入过去的时间
			getmessagelistandsessionbytimelineBean.setLongTimeline(YMTDateUtil.getDateBeforeOrNextSecond(-20).getTime());
			getmessagelistandsessionbytimelineCall.setData(getmessagelistandsessionbytimelineBean);
			getmessagelistandsessionbytimelineCall.callService();
			Logger.verifyEquals("Success",getmessagelistandsessionbytimelineCall.getString("Status"),"验证Status");
			checkYmtMessageSession(getmessagelistandsessionbytimelineBean);
			//查不到消息
			Logger.verifyEquals("[]",getmessagelistandsessionbytimelineCall.getJsonObject().get("Result").getAsJsonObject().get("YmtMessageList").toString(),"验证YmtMessageList为空");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}


	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetMessageListAndSessionByTimeline_002() {
		Logger.start(true,"用户获取私信消息和会话信息,给买手发送消息，isNew为yes");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			Integer userId = urrc.getUserid();
			SendMessageToSellerBean sendMessageToSellerBean = ImCallService.initSendMessageToSellerBean(userId,sellerId,"你好，im");
			ImCallService.SendMessageToSeller(sendMessageToSellerBean);

			getmessagelistandsessionbytimelineBean = ImCallService.initGetMessageListAndSessionByTimelineBean(userId,sellerId);
			getmessagelistandsessionbytimelineBean.setIsNew(MessageIsNewType.Yes);
			//传现在的时间
			getmessagelistandsessionbytimelineBean.setLongTimeline(YMTDateUtil.getDate().getTime());
			getmessagelistandsessionbytimelineCall.setData(getmessagelistandsessionbytimelineBean);
			getmessagelistandsessionbytimelineCall.callService();
			Logger.verifyEquals("Success",getmessagelistandsessionbytimelineCall.getString("Status"),"验证Status");
			//查不到消息
			checkYmtMessageSession(getmessagelistandsessionbytimelineBean);
			Logger.verifyEquals("[]",getmessagelistandsessionbytimelineCall.getJsonObject().get("Result").getAsJsonObject().get("YmtMessageList").toString(),"验证YmtMessageList为空");

			//传入过去的时间
			getmessagelistandsessionbytimelineBean.setLongTimeline(YMTDateUtil.getDateBeforeOrNextSecond(-10).getTime());
			getmessagelistandsessionbytimelineCall.setData(getmessagelistandsessionbytimelineBean);
			getmessagelistandsessionbytimelineCall.callService();
			Logger.verifyEquals("Success",getmessagelistandsessionbytimelineCall.getString("Status"),"验证Status");
			checkYmtMessageSession(getmessagelistandsessionbytimelineBean);
			//查到消息
			checkYmtMessageSession(getmessagelistandsessionbytimelineBean);
			checkMessage(getmessagelistandsessionbytimelineBean);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetMessageListAndSessionByTimeline_003() {
		Logger.start(true,"用户获取私信消息和会话信息,给买家发送消息,isNew为No");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			Integer userId = urrc.getUserid();
			SendMessageToBuyerBean sendMessageToBuyerBean = ImCallService.initSendMessageToBuyerBean(sellerId,userId,"你好，im");
			ImCallService.SendMessageToBuyer(sendMessageToBuyerBean);

			getmessagelistandsessionbytimelineBean = ImCallService.initGetMessageListAndSessionByTimelineBean(sellerId,userId);
			getmessagelistandsessionbytimelineBean.setIsNew(MessageIsNewType.No);
			//传现在的时间
			getmessagelistandsessionbytimelineBean.setLongTimeline(YMTDateUtil.getDate().getTime());
			getmessagelistandsessionbytimelineCall.setData(getmessagelistandsessionbytimelineBean);
			getmessagelistandsessionbytimelineCall.callService();
			Logger.verifyEquals("Success",getmessagelistandsessionbytimelineCall.getString("Status"),"验证Status");
			//查到消息
			checkYmtMessageSession(getmessagelistandsessionbytimelineBean);
			checkMessage(getmessagelistandsessionbytimelineBean);

			//传入过去的时间
			getmessagelistandsessionbytimelineBean.setLongTimeline(YMTDateUtil.getDateBeforeOrNextSecond(-20).getTime());
			getmessagelistandsessionbytimelineCall.setData(getmessagelistandsessionbytimelineBean);
			getmessagelistandsessionbytimelineCall.callService();
			Logger.verifyEquals("Success",getmessagelistandsessionbytimelineCall.getString("Status"),"验证Status");
			checkYmtMessageSession(getmessagelistandsessionbytimelineBean);
			//查不到消息
			checkYmtMessageSession(getmessagelistandsessionbytimelineBean);
			Logger.verifyEquals("[]",getmessagelistandsessionbytimelineCall.getJsonObject().get("Result").getAsJsonObject().get("YmtMessageList").toString(),"验证YmtMessageList为空");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetMessageListAndSessionByTimeline_004() {
		Logger.start(true,"用户获取私信消息和会话信息,给买家发送消息,isNew为Yes");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			Integer userId = urrc.getUserid();
			SendMessageToBuyerBean sendMessageToBuyerBean = ImCallService.initSendMessageToBuyerBean(sellerId,userId,"你好，im");
			ImCallService.SendMessageToBuyer(sendMessageToBuyerBean);

			getmessagelistandsessionbytimelineBean = ImCallService.initGetMessageListAndSessionByTimelineBean(sellerId,userId);
			getmessagelistandsessionbytimelineBean.setIsNew(MessageIsNewType.Yes);
			//传现在的时间
			getmessagelistandsessionbytimelineBean.setLongTimeline(YMTDateUtil.getDate().getTime());
			getmessagelistandsessionbytimelineCall.setData(getmessagelistandsessionbytimelineBean);
			getmessagelistandsessionbytimelineCall.callService();
			Logger.verifyEquals("Success",getmessagelistandsessionbytimelineCall.getString("Status"),"验证Status");
			//查不到消息
			checkYmtMessageSession(getmessagelistandsessionbytimelineBean);
			Logger.verifyEquals("[]",getmessagelistandsessionbytimelineCall.getJsonObject().get("Result").getAsJsonObject().get("YmtMessageList").toString(),"验证YmtMessageList为空");

			//传入过去的时间
			getmessagelistandsessionbytimelineBean.setLongTimeline(YMTDateUtil.getDateBeforeOrNextSecond(-10).getTime());
			getmessagelistandsessionbytimelineCall.setData(getmessagelistandsessionbytimelineBean);
			getmessagelistandsessionbytimelineCall.callService();
			Logger.verifyEquals("Success",getmessagelistandsessionbytimelineCall.getString("Status"),"验证Status");
			checkYmtMessageSession(getmessagelistandsessionbytimelineBean);
			//查不到消息
			checkYmtMessageSession(getmessagelistandsessionbytimelineBean);
			checkMessage(getmessagelistandsessionbytimelineBean);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetMessageListAndSessionByTimeline_005() {
		Logger.start(true,"用户获取私信消息和会话信息,给买家发送消息,消息中包含微信");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			Integer userId = urrc.getUserid();
			int fromUserId = 24635724;
			SendMessageToBuyerBean bean = ImCallService.initSendMessageToBuyerBean(fromUserId,userId,"你好，请加我微信");
			ImCallService.SendMessageToBuyer(bean);
			getmessagelistandsessionbytimelineBean.setCsId(bean.getCSId());
			getmessagelistandsessionbytimelineBean.setFromUserId(bean.getFromUserId());
			getmessagelistandsessionbytimelineBean.setIsNew(MessageIsNewType.Yes);
			getmessagelistandsessionbytimelineBean.setIsNotClearUnReadCount(true);
			getmessagelistandsessionbytimelineBean.setMessageCount(10);
			getmessagelistandsessionbytimelineBean.setToUserId(userId);
			getmessagelistandsessionbytimelineBean.setLongTimeline(YMTDateUtil.getBeforeOrNextDate(-1).getTime());
			getmessagelistandsessionbytimelineCall.setData(getmessagelistandsessionbytimelineBean);
			getmessagelistandsessionbytimelineCall.callService();
			Logger.verifyEquals("Success",getmessagelistandsessionbytimelineCall.getString("Status"),"验证Status");
			checkYmtMessageSession(getmessagelistandsessionbytimelineBean);
			checkMessage(getmessagelistandsessionbytimelineBean);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_GetMessageListAndSessionByTimeline_006() {
		Logger.start(true,"买手向买家发送消息,微信导流拦截 敏感词校验，买手可见，买家最后一条消息不可见,买手全部可见");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			Integer toUserId = urrc.getUserid();
			SendMessageToBuyerBean sendMessage1 = ImCallService.initSendMessageToBuyerBean(sellerId,toUserId,"你好");
			SendMessageToBuyerBean sendMessage2 = ImCallService.initSendMessageToBuyerBean(sellerId,toUserId,"加微信号");
			ImCallService.SendMessageToBuyer(sendMessage1);
			String messageId = ImCallService.SendMessageToBuyer(sendMessage2).get("messageId").getAsString();
			getmessagelistandsessionbytimelineBean = ImCallService.initGetMessageListAndSessionByTimelineBean(sellerId, toUserId);
			getmessagelistandsessionbytimelineCall.setData(getmessagelistandsessionbytimelineBean);
			getmessagelistandsessionbytimelineCall.callService();
			Logger.verifyEquals("Success",getmessagelistandsessionbytimelineCall.getString("Status"),"验证status");
			checkYmtMessageSession(getmessagelistandsessionbytimelineBean);
			checkMessage(getmessagelistandsessionbytimelineBean);
			getmessagelistandsessionbytimelineBean = ImCallService.initGetMessageListAndSessionByTimelineBean(toUserId, sellerId);
			getmessagelistandsessionbytimelineCall.setData(getmessagelistandsessionbytimelineBean);
			getmessagelistandsessionbytimelineCall.callService();
			Logger.verifyEquals("Success",getmessagelistandsessionbytimelineCall.getString("Status"),"验证status");
			checkYmtMessageSession(getmessagelistandsessionbytimelineBean);
			String ymtMessages = getmessagelistandsessionbytimelineCall.getJsonObject().get("Result").getAsJsonObject().get("YmtMessageList").toString();
			Logger.verifyEquals(false,ymtMessages.contains(messageId),"验证买手看不到消息");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetMessageListAndSessionByTimeline_007() {
		Logger.start(true,"用户获取私信消息和会话信息,给买手发送消息，验证bizstatus");
		try {
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			Integer userId = urrc.getUserid();
			SendMessageToSellerBean sendMessageToSellerBean = ImCallService.initSendMessageToSellerBean(userId,sellerId,"你好，im");
			JsonObject jo = ImCallService.SendMessageToSeller(sendMessageToSellerBean);
			String messageId = jo.get("messageId").getAsString();
			getmessagelistandsessionbytimelineBean = ImCallService.initGetMessageListAndSessionByTimelineBean(userId,sellerId);
			getmessagelistandsessionbytimelineBean.setIsNew(MessageIsNewType.No);
			//传现在的时间
			getmessagelistandsessionbytimelineBean.setLongTimeline(YMTDateUtil.getDate().getTime());
			getmessagelistandsessionbytimelineCall.setData(getmessagelistandsessionbytimelineBean);
			getmessagelistandsessionbytimelineCall.callService();
			Logger.verifyEquals("Success",getmessagelistandsessionbytimelineCall.getString("Status"),"验证Status");
			//查到消息
			checkYmtMessageSession(getmessagelistandsessionbytimelineBean);
			checkMessage(getmessagelistandsessionbytimelineBean);
			setBizStatus(messageId, 1);
			getmessagelistandsessionbytimelineCall.callService();
			Logger.verifyEquals("Success",getmessagelistandsessionbytimelineCall.getString("Status"),"验证Status");
			String ymtMessageList = getmessagelistandsessionbytimelineCall.getJsonObject().get("Result").getAsJsonObject().get("YmtMessageList").getAsJsonArray().toString();
			List<com.ymatou.iapi.im.parameter.YmtMessage > ymtMessages = (List<com.ymatou.iapi.im.parameter.YmtMessage>)FormatUtil.GSONToObject(ymtMessageList, new TypeToken<List<com.ymatou.iapi.im.parameter.YmtMessage >>(){}.getType());
			Logger.debug("ymtMessages:"+ymtMessages);
			Logger.verifyEquals(1,ymtMessages.stream().filter(x->x.getMessageId().equals(messageId)).findFirst().get().getBizStatus(),"验证status");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}